(function($) {
	$(document).ready(function(e) {
		
		var oTable = $('#table-editable').dataTable();
		
		oTable.$('.editable-column').editable( 'modul/admin_jadwal_praktikum/item_update.php', {
			loadurl : 'modul/select/hari_select.php',
			type   : 'select',
			"callback": function( sValue, y ) {
				if($(this).parent().attr('id')=='-'){
					var aPos = oTable.fnGetPosition( this );
					var arr = sValue.split(',');
					oTable.fnUpdate( arr[1]+" saved", aPos[0], aPos[1] );
					$(this).parent().attr('id',arr[0]);
				}else{
					oTable.fnUpdate( sValue, aPos[0], aPos[1] );
				}
				
			},
			"submitdata": function ( value, settings ) {
				return {
					"siswa" : $(this).parent().attr('data-siswa'),
					"materi" : $(this).parent().attr('data-materi'),
					"row_id": this.parentNode.getAttribute('id'),
					"column": oTable.fnGetPosition( this )[2]
				};
			},
			submit     : "ok",
			"height": "14px",
			"width": "100%"
		} );
		
		$('.timepicker3').datetimepicker({
		  pickDate: false
		});
		
		$(".editable-time-column").editable("modul/admin_jadwal_praktikum/item_update.php", { 
				type       : "time",
				"callback": function( sValue, y ) {
				//	alert(sValue);
					if($(this).parent().attr('id')=='-'){
						var aPos = oTable.fnGetPosition( this );
						var arr = sValue.split(',');
						oTable.fnUpdate( arr[1]+" saved", aPos[0], aPos[1] );
						
						$(this).parent().attr('id',arr[0]);
					}else{
						oTable.fnUpdate( sValue, aPos[0], aPos[1] );
					}
					
				},
				"submitdata": function ( value, settings ) {
					return {
						"siswa" : $(this).parent().attr('data-siswa'),
						"materi" : $(this).parent().attr('data-materi'),
						"row_id": this.parentNode.getAttribute('id'),
						"column": oTable.fnGetPosition( this )[2]
					};
				},
				submit     : "ok",
				style      : "display: inline",
				tooltip    : "Click to edit...",
				"height": "14px",
				"width": "100%"
		});
		
	});
}) (jQuery);
